<template>
  <div class="monitor-container">
    <div class="monitor-index">{{ indexFormat }}</div>
    <img class="monitor-media" :src="data.src" />
    <div class="monitor-operation-container" @click="onClickFullScreen">
      <i class="operation-icon iconfont icon-position"></i>
      <div class="operation-desc">{{ data.position }}</div>
      <i class="operation-icon_full-screen iconfont icon-full-screen"></i>
    </div>
  </div>
</template>

<script>
export default {
  name: "MonitorCard",
  props: {
    data: {
      type: Object,
      default: () => ({})
    },
    index: {
      type: Number,
      default: 1
    }
  },
  data() {
    return {};
  },

  computed: {
    indexFormat() {
      return this.index < 10 ? `0${this.index}` : this.index;
    }
  },

  methods: {
    /**
     * 点击全屏方法
     */
    onClickFullScreen() {
      this.$emit("fullScreen", this.data);
    }
  }
};
</script>

<style lang="less" scoped>
.monitor-container {
  display: flex;
  position: relative;
  width: 100%;
  height: 100%;

  .monitor-index {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.625rem;
    background: linear-gradient(
      90deg,
      rgba(11, 109, 218, 0.3) 0%,
      rgba(68, 170, 255, 0.8) 81%,
      #64baff 100%
    );
    border-radius: 0px 0px 0.625rem 0px;
    font-size: 0.875rem;
    font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
    font-weight: bold;
    color: #fff;
    line-height: 0.875rem;
  }

  .monitor-media {
    width: 100%;
    height: 100%;
  }

  .monitor-operation-container {
    position: absolute;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: baseline;
    width: 100%;
    padding: 0.125rem 0.5rem;
    box-sizing: border-box;

    .operation-desc {
      margin-left: 0.3125rem;
      font-size: 0.75rem;
      font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
      font-weight: 400;
      color: #fff;
      line-height: 0.875rem;
    }

    .operation-icon,
    .operation-icon_full-screen {
      flex-shrink: 0;
      font-size: 0.8125rem;
      color: #fff;
    }

    .operation-icon_full-screen {
      margin-left: auto;
    }
  }
}
</style>
